package com.jrx.anytxn.transaction.mapper.ext;

import com.jrx.anytxn.transaction.entity.TlGlInterfaceInfo;
import com.jrx.anytxn.transaction.mapper.base.TlGlInterfaceInfoMapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface ExtTlGlInterfaceInfoMapper extends TlGlInterfaceInfoMapper {

    /**
     * 查询所有信息
     *
     * @param tenantId 租户id
     *                 date: 2019/9/24 0024 下午 14:48
     * @return java.util.List<com.jrx.anytxn.transaction.entity.TlGlInterfaceInfo>
     * @author fan.yang
     */
    List<TlGlInterfaceInfo> getAllTlGlInterfaceInfo(@Param(value = "tenantId") String tenantId, @Param("customerId") String customerId, @Param("loanId") String loanId);

    /**
     * 根据主键及用户id、租户id查询gl流水信息
     *
     * @param id         主键
     * @param customerId 客户id
     * @param tenantId   租户id
     * @return gl流水
     */
    TlGlInterfaceInfo selectByPrimaryKeyAndCusIdAndTenantId(@Param(value = "id") Long id,
                                                            @Param(value = "customerId") String customerId,
                                                            @Param(value = "tenantId") String tenantId);
    /**
     * 根据主键及用户id、租户id查询gl流水信息
     *
     * @param glFlowno   流水号
     * @param customerId 客户id
     * @param tenantId   租户id
     * @return gl流水
     */
    TlGlInterfaceInfo selectByGlFlownoAndCusIdAndTenantId(@Param(value = "glFlowno") String glFlowno,
                                                          @Param(value = "customerId") String customerId,
                                                          @Param(value = "tenantId") String tenantId);

    /**
     * 根据日期和机构号查询总账流水list
     *
     * @param date 日期
     * @return java.util.List<com.jrx.anytxn.transaction.entity.TlGlInterfaceInfo>
     * @author fan.yang
     * date: 2019/9/24 0024 下午 14:52
     */
    List<TlGlInterfaceInfo> getByDateAndOrgId(@Param("date") Date date);

    /**
     * 批量插入还款流水分配信息
     *
     * @param glInterfaceInfos
     * @return
     */
    int batchInsertSelective(List<TlGlInterfaceInfo> glInterfaceInfos);

    /**
     * 获取订单下所有GL流水
     *
     * @param loanId
     * @param customerId
     * @param tenantId
     * @return
     */
    List<TlGlInterfaceInfo> selectAllGl(@Param(value = "loanId") String loanId,
                                        @Param(value = "customerId") String customerId,
                                        @Param(value = "tenantId") String tenantId);

    /**
     * 获取订单下所有GL流水
     *
     * @param loanId
     * @param customerId
     * @param tenantId
     * @return
     */
    List<TlGlInterfaceInfo> selectByTxnCodeAllGl(@Param(value = "loanId") String loanId,
                                                 @Param(value = "customerId") String customerId,
                                                 @Param(value = "txnCode") String txnCode,
                                                 @Param(value = "tenantId") String tenantId);

    /**
     * 查询数量
     * @param tenantId
     * @param businessDate
     * @param txnCodes
     * @param thirdChannel
     * @return
     */
    int countByBusinessDateAndTxnCode(@Param("tenantId") String tenantId, @Param("businessDate") Date businessDate, @Param("txnCodes") List<String> txnCodes, @Param("thirdChannel") String thirdChannel);

    /**
     * 查询金额
     * @param tenantId
     * @param businessDate
     * @param txnCodes
     * @param thirdChannel
     * @return
     */
    BigDecimal sumByBusinessDateAndTxnCode(@Param("tenantId") String tenantId, @Param("businessDate") Date businessDate, @Param("txnCodes") List<String> txnCodes, @Param("thirdChannel") String thirdChannel);
}